<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="/css/public.css" media="all">
</head>
<body>
<div class="layuimini-container" id="app">
    <div class="layuimini-main">
        <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
            <legend>批量踢人</legend>
        </fieldset>
        <form class="layui-form" action="" lay-filter="example">

            <div class="layui-inline">
                <label class="layui-form-label">选择区服:</label>
                <div class="layui-input-inline">
                    <select name="gameArea" class="layui-select" >

                        <option v-for="(item,index) in services" :value="item.server_id" :selected="index==0">{{item.name}}</option>
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">角色ID</label>
                <div class="layui-input-inline">
                    <textarea name="roles"></textarea>
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                </div>
            </div>
        </form>

    </div>
</div>
<script src="/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script src="/js/common.js?v=5" charset="utf-8"></script>
<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<script>
    var form = null;
    new Vue({
        el:"#app",
        data:{
            services: JSON.parse(localStorage.getItem('services')),
            formData:{
                show:null,
                status:null,
                busy_status:null,
                pay_status:null,
                white_status:"0",
            }
        },
        updated:function(){
            form.render();
        },
        methods:{

        },
        mounted:function() {
            var _this = this;
            layui.use(['form', 'laydate'], function () {
                form = layui.form;
                var layer = layui.layer, $ = layui.$,laydate=layui.laydate;
                //监听提交
                form.on('submit(demo1)', function (data) {
                    var formData = data.field;
                    console.log('提交的参数',formData)
                    var roles = formData.roles.split('\n');
                    if (roles.length > 21) {
                        alert('输入的角色 ID 最多 20 个');
                        return false;
                    }
                    $.post('/admin/gameRole/ti',formData,function (res) {
                        if (res.code === 0){
                            layer.msg('操作成功',{icon:1,time:500},function(){
                                //location.reload();
                            })
                        }else {
                            layer.msg(res.msg,{icon:5})
                        }
                    })
                    return false;
                });
                form.on('radio(status)',function(data){
                    _this.formData.status = data.value;
                })
                form.render();
            })
        }
    });
</script>

</body>
</html>